package com.jqr.activity.school.http;

import java.util.function.Consumer;

public abstract class ErrorConsumer implements Consumer<Throwable> {
    @Override
    public void accept(Throwable throwable) {
        ApiException ex;
        if(throwable instanceof ApiException){
            ex=(ApiException) throwable;
        }
        else {
            ex=ApiException.handleException(throwable);
        }
        error(ex);
    }

    protected abstract void error(ApiException e);
}
